<?php
/**
 * Created by PhpStorm.
 * User: gaoliang
 * Date: 2017/5/24
 * Time: 11:32
 */

/**
 * 判断是否为https链接
 * @return bool
 */
function isHttps()
{
    if ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off')
    {
        return TRUE;
    }
    elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
    {
        return TRUE;
    }
    elseif ( ! empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off')
    {
        return TRUE;
    }
    return FALSE;
}

/**
 * 返回http的类型
 * @return string http/https
 */
function getHttpType() {
    return isHttps()?'https':'http';
}